import java.io.IOException;

/**
 * CmdExecuter.java
 *
 * Copyright (C) 2013 Timo Tegtmeier.
 * All rights reserved.
 */

public class CmdExecuter {

    public static int GotIOException = -127;
    public static int GotInterruptedException = -128;

    public static int executeCmd(String cmd) {
        Runtime run = Runtime.getRuntime();
        try {
            Process pr = run.exec(cmd);
            pr.waitFor();
            return pr.exitValue();
        } catch(IOException e) {
            return GotIOException;
        } catch(InterruptedException e) {
            return GotInterruptedException;
        }
    }
}
